import java.io.File;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;
public class  Client_Main{ 
	private PrintWriter writer;
        Socket socket; 
        private void client() { 
            System.out.println("尝试连接\n");
            File file =new File("16012019.txt");
            try { 
                socket = new Socket("10.43.11.121", 8080); 
                writer = new PrintWriter(socket.getOutputStream(), true);
               System.out.println("完成连接");
               Scanner sc=new Scanner(socket.getInputStream());
               System.out.println(sc.nextLine());
               System.out.println("我（客户机）：");
               Scanner sc1=new Scanner(System.in);
               while(true){
            	   String data=sc1.nextLine();
            	   writer.println(data);
            	   writer.flush();
            	   String data1=sc.nextLine();
            	   System.out.println("服务机："+data1);
            	   System.out.println("我（客户机）：");
               }
            } catch (Exception e) {
                e.printStackTrace(); 
            }
        }
        
        public static void main(String[] args) { 
            Client_Main clien = new Client_Main(); 

            clien.client();
        }
 }

